package Java多线程技术.第3章.一生产多消费;

/*
* 解决wait条件改变与假死
* 1、条件发生改变时没有得到及时响应，所以多个呈wait状态的线程被唤醒，
* 继而去执行remove(0)代码出现异常，解决办法是将if语句改为while语句
*
* 2、假死情况 解决办法是将notify方法改成notifyAll方法
*
*/

public class Run2 {
    public static void main(String[] args) {
        MyStack2 myStack2 = new MyStack2();

        P2 p2 = new P2(myStack2);
        C2 c21 = new C2(myStack2);
        C2 c22 = new C2(myStack2);
        C2 c23 = new C2(myStack2);

        PThread2 pThread2 = new PThread2(p2);

        CThread2 cThread21 = new CThread2(c21);
        CThread2 cThread22 = new CThread2(c22);
        CThread2 cThread23 = new CThread2(c23);

        pThread2.start();

        cThread21.start();
        cThread22.start();
        cThread23.start();
    }
}
